package geektime.spring.springbucks.dao;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

import geektime.spring.springbucks.model.Coffee;

@Mapper
public interface CoffeeDao {
    @Select("select * from t_coffee order by id")
    List<Coffee> findAllWithRowBounds(RowBounds rowBounds);

    @Select("select * from t_coffee")
    List<Coffee> findAllWithParam(@Param("pageNum") int pageNum,
                                  @Param("pageSize") int pageSize);

    @Select("select * from t_coffee")
    public List<Coffee> allCoffees();

    @Select("select * from t_coffee where name=#{name}")
    public Coffee findCoffeeByName(Coffee coffee);
    // @Update("<script> " + "update t_coffee" +
    // "<set>"+  "<if test='uname!=null'>uname=#{uname},</if>"+
    // "<if test='upassword!=null'>upassword=#{upassword},</if>"+
    // "</set>"+ "where uid=#{uid}"+
    // " </script> ")
    @Update("update t_coffee set name=#{name}, price=#{price} where name=#{name}")
    public int Update(Coffee coffee);

}